package service.impl;

import bean.dto.CostPage;
import bean.vo.CostOption;
import bean.vo.PeopleCostVo;
import bean.vo.RoomListOption;
import dao.CostManagementDao;
import dao.ExpenseTypeDao;
import dao.impl.CostManagementDaoImpl;
import dao.impl.ExpenseTypeDaoImpl;
import service.CostManagementService;

import java.util.List;

/**
 * service.impl
 * User: xlh
 * Date: 2024/12/18 9:12
 * motto:推到高塔
 * Description:
 * Version: V1.0
 */
public class CostManagementServiceImpl implements CostManagementService {
    private CostManagementDao costManagementDao =new CostManagementDaoImpl();
    @Override
    public List<RoomListOption> findAllRoomList() {
        return costManagementDao.findAllRoomList();
    }

    @Override
    public Long findByTotal(CostPage costPage) {
        //验证有没有值
        if(costPage.getTypeTime()==null  ||  costPage.getTypeTime().trim().length()==0){
            costPage.setTypeTime(null);
        }
        if(costPage.getTypeName()==null  ||  costPage.getTypeName().trim().length()==0){
            costPage.setTypeName(null);
        }
        if(costPage.getRoomNumber()==null  ||  costPage.getRoomNumber().trim().length()==0){
            costPage.setRoomNumber(null);
        }
        return   costManagementDao.findByTotal(costPage);
    }

    @Override
    public List<CostOption> findByPage(CostPage costPage) {
        return costManagementDao.findByPage(costPage);
    }

    @Override
    public boolean updateCostById(PeopleCostVo peopleCostVo) {
        return costManagementDao.updateCostById(peopleCostVo)>0;
    }

    @Override
    public boolean Cuijiao(PeopleCostVo peopleCostVo) {
        return costManagementDao.Cuijiao(peopleCostVo)>0;
    }

    @Override
    public List<CostOption> loadAll(CostPage costPage) {
        return costManagementDao.loadAll(costPage);
    }
}
